package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.common.result.ResultCodeEnum;
import com.atguigu.tingshu.model.album.AlbumAttributeValue;
import com.atguigu.tingshu.model.album.BaseAttribute;
import com.atguigu.tingshu.model.album.BaseCategory3;
import com.atguigu.tingshu.model.album.BaseCategoryView;
import com.atguigu.tingshu.vo.album.AlbumCategoryVo;
import com.atguigu.tingshu.vo.album.AlbumInfoVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@Slf4j
@SuppressWarnings({"unchecked", "rawtypes"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;
	@GetMapping("/getBaseCategoryList")
	public Result<List<AlbumCategoryVo>> getBaseCategoryList(){
		//调用服务层查询分类
		List<AlbumCategoryVo> categoryList = baseCategoryService.getBaseCategoryList();
		return Result.build(categoryList, ResultCodeEnum.SUCCESS);
	}
	@GetMapping("/findAttribute/{category1Id}")
	public Result<List<BaseAttribute>> findAttribute(@PathVariable(value = "category1Id") Long category1Id){
		List<BaseAttribute> attributeValueList = baseCategoryService.findAttribute(category1Id);
		return Result.build(attributeValueList,ResultCodeEnum.SUCCESS);
	}
	@GetMapping("getCategoryView/{category3Id}")
	public Result<BaseCategoryView> getCategoryView(@PathVariable(value = "category3Id") Long c3Id){
		BaseCategoryView baseCategoryView = baseCategoryService.getCategoryView(c3Id);
		return Result.build(baseCategoryView,ResultCodeEnum.SUCCESS);
	}
	@GetMapping("getBaseCategoryList/{category1Id}")
	public Result<AlbumCategoryVo> getBaseCategoryList(@PathVariable(value = "category1Id") Long category1Id){
		AlbumCategoryVo albumCategoryVo = baseCategoryService.getBaseCategoryList(category1Id);
		return Result.build(albumCategoryVo,ResultCodeEnum.SUCCESS);
	}
	@GetMapping("findTopBaseCategory3/{category1Id}")
	public Result<List<BaseCategory3>> findTopBaseCategory3(@PathVariable(value = "category1Id") Long c1Id){
		List< BaseCategory3> baseCategory3List = baseCategoryService.findTopBaseCategory3(c1Id);
		return Result.build(baseCategory3List,ResultCodeEnum.SUCCESS);
	}

}

